package com.xayy.mgt.enums;

import lombok.Getter;

@Getter
public enum ProjectItemEnum {

    FUNCTIONITEM(1, "功能项"),

    PERFORMANCEITEM(2, "性能项");

    private Integer code;
    private String name;

    ProjectItemEnum(Integer code, String name) {
        this.name = name;
        this.code = code;
    }

    public static String valueof(Integer index) {
        for (ProjectItemEnum projectItemEnum : values()) {
            if (projectItemEnum.getCode() == index) {
                return projectItemEnum.name;
            }
        }
        return "";
    }

    public static Integer valueof(String name) {
        for (ProjectItemEnum projectItemEnum : values()) {
            if ( name.equals(projectItemEnum.name())) {
                return projectItemEnum.code;
            }
        }
        return null;
    }
}
